<?php

Raise::load('core.io.file.RaiseFile');

/**
 *TestCoreRaiseFile
 * Testing unit of 'phpraise/core/RaiseFile.php'
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseFile extends RaiseTest {
    
    public static function testClass(){

        self::assertClassExists('RaiseFile');
        self::assertClassExtends('RaiseFile', 'RaiseObject');
        
        self::assertConstantDefined(
                array(
                    'RaiseFile::TYPE_DIR',
                    'RaiseFile::TYPE_FILE',
                    'RaiseFile::TYPE_SOCKET',
                    'RaiseFile::TYPE_LINK',
                    'RaiseFile::TYPE_OTHERS'
                    )
                );
        
    }
    
    public static function testFile(){

        $file = new RaiseFile('testFile.raise');
        self::assertObjectClass($file, 'RaiseFile');
        self::assertFileNotExist($file->pathname());
        $file->create();
        self::assertFileExist($file->pathname());

        $s = 'testing file content';
        $file->write($s);
        self::assertStrictEqual($file->read(), $s);

        self::assertStrictEqual($file->size(), strlen($s));

        $file->delete();
        self::assertFileNotExist($file->pathname());

    }
    
}

